package com.example.shop_2208.fragment

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.example.shop_2208.entity.AddCarEntityResult
import com.example.shop_2208.mvvm.BaseViewModel
import com.example.shop_2208.net.ApiServer
import kotlinx.coroutines.launch
import okhttp3.MultipartBody

class MineViewModel:BaseViewModel() {

    val success = MutableLiveData<AddCarEntityResult>()
    val fail = MutableLiveData<String>()

    fun updateIcon(part: MultipartBody.Part){
        viewModelScope.launch {
            try {
                success.value = apiServer.updateIcon(part)
            }catch (e:Exception){
                fail.value = e.message
            }
        }
    }
}